<layout name='Layout/layout_main' />
<tagLib name="html" />
<script type="text/javascript">
	var manager = null;
	function add() {
		pid = $("#id").val();
		$("#form_data :input :not(:button)").each(function() {
			$(this).val("");
		});
		$("#form_data :text").each(function() {
			$(this).val("");
		});
		$("#pid").val(pid);
		$("#opmode").val("add");
	};

	function save() {
		if(check_form("form_data")){
			sendForm("form_data", "{:U('save')}","__URL__");
		}
	}

	function test() {
		form_search.submit();
	};

	function select_pid() {
		winopen("{:U('winpop')}", 600, 400);
	}

	function showdata(result) {
		for (var s in result.data){
			set_val(s,result.data[s]);
		}
		$("#dept_name").val($("#dept_list option[value='" + $("#pid").val() + "']").text());
		$("#opmode").val("edit");
	}


	$(document).ready(function() {
		$(".sub_left_menu .tree_menu  a").click(function() {
			$(".sub_left_menu .tree_menu  a").each(function() {
				$(this).attr("class", "");
			});
			$(this).attr("class","active");
			sendAjax("{:U('read')}", "id=" + $(this).attr("node"), function(data) {
				showdata(data);
			});
			return false;
		})
	});

</script>
<div class="admin" >
	<div class="row-fluid title">
		<span>部门管理</span>
	</div>
	<div class="row-fluid operate" >
		<div class="right">
			<a onclick="add()" class="btn">新增</a>
			<a onclick="save()"  class="btn">保存</a>
		</div>
	</div>
	<!-- 功能操作区域结束 -->
	<!-- 列表显示区域  -->
	<div class="row-fluid">
		<div class="span4 sub_left_menu">
			<div class="wrap">
				<?php echo $menu ?></div>
		</div>
		<div class="span8 sub_content ">
			<form id="form_data" name="form_data" method="post" action="">
				<input type="hidden" name="id" id="id">				
				<input type="hidden" name="ajax" id="ajax" value="1">
				<input type="hidden" name="opmode" id="opmode" value="">
				<html:select id="dept_list" name="dept_list"  options="dept_list" style="dis"/>
				<div class="row-fluid form_box">
					<div class="row-fluid form-horizontal">
						<div class="control-group">
							<label class="control-label" for="dept_no">编码*：</label>
							<div class="controls">
								<input type="text" id="dept_no" name="dept_no" check="require" msg="请输入分类编码"></div>
						</div>
					</div>
					<div class="row-fluid form-horizontal">
						<div class="control-group">
							<label class="control-label" for="name">名称*：</label>
							<div class="controls">
								<input type="text" id="name" name="name" check="require" msg="请输入名称"></div>
						</div>
					</div>
					<div class="row-fluid form-horizontal">
						<div class="control-group">
							<label class="control-label" for="short">简称*：</label>
							<div class="controls">
								<input type="text" id="short" name="short" check="require" msg="请输入简称"></div>
						</div>
					</div>
					<div class="row-fluid form-horizontal">
						<div class="control-group">
							<label class="control-label" for="dept_grade_id">部门级别：</label>
							<div class="controls">
								<html:select id="dept_grade_id" name="dept_grade_id" style="medium"  first="选择部门级别" options="dept_grade_list" />
							</div>
						</div>
					</div>
					<div class="row-fluid form-horizontal">
						<div class="control-group">
							<label class="control-label" for="dept_name">上级部门：</label>
							<div class="controls">
								<div class="input-append">
									<input name="dept_name" class="val" id="dept_name" type="text" msg="请选择上级部门" check="require" source="{:U('dept/json')}" />
									<input name="pid" class="key" id="pid" type="hidden" msg="请选择上级部门" check="require" />
									<button class="btn" onclick="select_pid()" type="button">选择</button>
								</div>
								<div class="search dropdown ">
									<ul class="dropdown-menu"></ul>
								</div>
							</div>							
						</div>
					</div>
					<div class="row-fluid form-horizontal">
						<div class="control-group">
							<label class="control-label" for="sort">排序：</label>
							<div class="controls">
								<input type="text" id="sort" name="sort" readonly></div>
						</div>
					</div>
					<div class="row-fluid form-horizontal">
						<div class="control-group">
							<label class="control-label" for="is_del">状态：</label>
							<div class="controls">
								<select   name="is_del" id="is_del">
									<option  value="0">启用</option>
									<option value="1">禁用</option>
								</select>
							</div>
						</div>
					</div>
					<div class="row-fluid form-horizontal">
						<div class="control-group">
							<label class="control-label" for="is_del">状态：</label>
							<div class="controls">
								<textarea id="remark" name="remark" class="span12"></textarea>
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>